from time import sleep
import uiautomation
import pyautogui
class menzhenyishengzhan():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()
        #导航栏
        fuwudengji = his.ButtonControl(ClassName='Button',  Name="服务登记") #服务登记
        rizhichaxun = his.ButtonControl(ClassName='Button',  Name="日志查询") #日志查询
        zhuyuantongzhi = his.ButtonControl(ClassName='Button',  Name="住院通知") #住院通知
        zhengduanzhengming = his.ButtonControl(ClassName='Button',  Name="诊断证明") #诊断证明
        xinzu = his.ButtonControl(ClassName='Button', Name="新组")#新组
        baocun = his.ButtonControl(ClassName='Button', Name="保存",AutomationId='btnSave')
        #居民登记列表定位
        dengdai = his.RadioButtonControl(ClassName='RadioButton', AutomationId='rbWaiting', Name="等待")  # 等待
        yifuwu = his.RadioButtonControl(ClassName='RadioButton', AutomationId='rbDone', Name="已服务")  # 已服务
        quanbu = his.RadioButtonControl(ClassName='RadioButton', AutomationId='rbAll', Name="全部")  # 全部
        wodebingren = his.RadioButtonControl(ClassName='RadioButton', AutomationId='rbMyPat', Name="我的病人")  #我的病人
        quanbubingren = his.RadioButtonControl(ClassName='RadioButton',AutomationId='rball',Name="全部病人") #全部病人
        xingmingshurukuang = his.CustomControl(ClassName='MenZhenChuFang',AutomationId='menzhenCFWin').GroupControl(ClassName='GroupBox',Name="居民登记列表",).EditControl(ClassName='TextBox')
        shuaxin = his.ButtonControl(AutomationId='btnRefresh', Name='刷新')#刷新
        dianzipingzheng = his.ButtonControl(AutomationId='btnRefresh', Name='电子凭证')  # 电子凭证
        huanzhe1 = his.DataItemControl(ClassName='DataGridRow',Name="Yuanbo.ChssClient.OutFeeManager.Model.MZCF.SQ_JMFWDJWrapper",foundIndex=1) #搜索出的第一个患者
        tishichuangkou = his.WindowControl(ClassName='Window', Name="科玛奇医院信息管理系统").WindowControl(ClassName='Window',Name="提示")#提示窗口
        tishiqueding = his.ButtonControl(ClassName='Button',Name="确定", AutomationId='OkBtn')
        tishiquxiao = his.ButtonControl(ClassName='Button',Name="取消", AutomationId='CancelBtn')
        yulanchuangkou = his.WindowControl(ClassName='Window',Name="预览")#打印预览窗口
        yulanguanbi = yulanchuangkou.ButtonControl(ClassName='Button',Name="关闭")

        xinzenghang = his.MenuControl(ClassName='ContextMenu').MenuItemControl(ClassName='MenuItem',Name="新增行")

        def add_hang(self,num):
                for i in range(num):
                        uiautomation.RightClick(1210, 515)
                        self.xinzenghang.Click()
#居民登记列表
        #点击全部
        def click_dendai_btn(self):
                self.dengdai.Click()
        #点击已服务
        def click_yifuwu_btn(self):
                self.yifuwu.Click()
        #点击全部
        def click_quanbu_btn(self):
                self.quanbu.Click()
        #点击我的病人
        def click_wodebingren_btn(self):
                self.wodebingren.Click()
        #点击全部病人
        def click_quanbubingren_btn(self):
                self.quanbubingren.Click()
        #点击刷新
        def click_shuaxin_btn(self):
                self.shuaxin.Click()
        #点击电子凭证
        def click_dianzipingzheng_btn(self):
                self.dianzipingzheng.Click()
        #姓名输入框
        def input_name(self,name):
                self.xingmingshurukuang.Click()
                pyautogui.hotkey('ctrl', 'a')
                pyautogui.press('back')
                self.xingmingshurukuang.SendKeys(name)
                # pyautogui.click(x=200, y=233)
                # sleep(0.5)
                # pyautogui.hotkey('ctrl', 'v')
        #双击患者
        def double_click_huanzhe_btn(self):
                self.huanzhe1.DoubleClick()
                sleep(4)

#导航窗
        #点击服务登记
        def click_fuwudengji_btn(self):
                self.fuwudengji.Click()
        #点击日志查询
        def click_rizhichaxun(self):
                self.rizhichaxun.Click()
        #点击住院通知
        def click_zhuyuantongzhi_btn(self):
                self.zhuyuantongzhi.Click()
        #点击诊断证明
        def click_zhengduanzhengming_btn(self):
                self.zhengduanzhengming.Click()

        #点击新组
        def click_xinzu_btn(self):
                self.xinzu.Click()

        #选择添加多少个新组
        def add_xinzu(self,num):
                num1 = int(num)
                for i in range(num1):
                        self.xinzu.Click()

        #点击保存
        def click_savebtn(self):
                self.baocun.Click()
                sleep(2)

        #点击打印预览关闭按钮
        def click_yl_close(self):
                self.yulanguanbi.Click()

        #点击提示确定按钮
        def click_ts_ok(self):
                self.tishiqueding.Click()

        #双击空白处
        def click_blank(self):
                pyautogui.moveTo(x=1861, y=95, duration=1)
                pyautogui.click(x=1861, y=130, clicks=2, interval=0.3, button='left')


